#include "LoadState.h"
#include "LoadGameObjects.h"
#include "Game.h"
#include "TestState.h"
#include "DX11ShaderManager.h"
#include "DX11TextureManager.h"
#include "ObjMeshManager.h"
#include "ConfigManager.h"
#include "Text.h"
#include "DX11HelpfulFunctions.h"
#include "ScreenManager.h"
#include "TitleScreenState.h"

LoadState::LoadState()
{

}

void LoadState::Draw()
{

}

void LoadState::Update()
{

}

void LoadState::LoadMeshes()
{
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/minecraft_text.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/eras_text.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/default_texture.png");
	TheDX11ShaderManager::Instance()->LoadShader("FontShader", L"FontShader.hlsl", "PS", "VS");

	TheFontManager::Instance()->LoadFont("eras");
	TheFontManager::Instance()->LoadFont("mc");
	
	DX11::ClearColour(0.0f, 0.0f, 0.0f, 1.0f);

	m_loadingText.Update("Loading Meshes");
	m_loadingText.Translate(D3DXVECTOR3(0.0f, 0.0f, 0.0f));
	m_loadingText.Draw();

	TheScreenManager::Instance()->FlipBuffers();
	

	//TheObjMeshManager::Instance()->LoadObj("../../Assets/crate_test.obj", "crate", L"Tutorial02.fx");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/sphere_test2.obj", "sphere", L"Tutorial02.hlsl");
	////TheObjMeshManager::Instance()->LoadObj("../../Assets/torus_test.obj", "torus", L"Tutorial02.fx");
	//TheObjMeshManager::Instance()->LoadObj("../../Assets/torus_test2.obj", "torus2", L"Tutorial02.fx");
	//TheObjMeshManager::Instance()->LoadObj("../../Assets/pyramid_test.obj", "pyramid", L"Tutorial02.fx");
	////TheObjMeshManager::Instance()->LoadObj("../../Assets/honda_jazz_1.obj", "honda_jazz", L"Tutorial02.fx");
	////TheObjMeshManager::Instance()->LoadObj("../../Assets/textured_rock_vsmall.obj", "rock", L"Tutorial02.fx");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/crate_textured.obj", "crate_textured", L"Tutorial02.hlsl");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/maze_floor.obj", "maze_floor", L"MazeFloorShader.hlsl");
	//TheObjMeshManager::Instance()->LoadObj("../../Assets/ground.obj", "floor", L"FloorShader.hlsl");
	//TheObjMeshManager::Instance()->LoadObj("../../Assets/post_process_quad.obj", "post_process", L"PostProcess.hlsl");
	////TheDX11ShaderManager::Instance()->LoadShader("post_process", "PostProcess.hlsl", "PS", "VS");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/agent.obj", "agent", L"Tutorial02.hlsl");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/agent_cube.obj", "agent_cube", L"Tutorial02.hlsl");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/player_cube.obj", "player_cube", L"Tutorial02.hlsl");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/mini_map_quad.obj", "mini_map", L"MiniMapShader.hlsl");
	TheObjMeshManager::Instance()->LoadObj("../../Assets/crate_test.obj", "title_quad", L"TitleScreenQuad.hlsl");
		
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/player_arrow.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/floor_texture.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/wall_texture_small.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/fog_of_war.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/enemy_texture.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/title_image.png");
	TheDX11TextureManager::Instance()->LoadTexture(L"../../Assets/options_image.png");
}

void LoadState::LoadShaders()
{	
	DX11::ClearColour(0.0f, 0.0f, 0.0f, 1.0f);
	m_loadingText.Update("Loading Shaders");
	m_loadingText.Translate(D3DXVECTOR3(0.0f, 0.0f, 0.0f));
	m_loadingText.Draw();

	TheScreenManager::Instance()->FlipBuffers();


	//TheDX11ShaderManager::Instance()->LoadShader("TerrainShader", L"TerrainShader.hlsl", "PS", "VS");
	//TheDX11ShaderManager::Instance()->LoadShader("WaterShader", L"WaterShader.hlsl", "PS", "VS");
	//TheDX11ShaderManager::Instance()->LoadShader("LightViewRender", L"LightViewRender.hlsl", "PS", "VS");
	//TheDX11ShaderManager::Instance()->LoadShader("ShadowPostProcessor", L"ShadowPostProcessor.hlsl", "PS", "VS");
	//TheDX11ShaderManager::Instance()->LoadShader("Reflection", L"Reflection.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("CrateShader", L"CrateShader.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("DefaultTexture", L"DefaultTextureShader.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("lightShader", L"Tutorial02.hlsl", "PSSolid", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("RoomShader", L"Tutorial02.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("DefaultColour", L"Tutorial02.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("DepthBuffer", L"DepthBuffer.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("MiniMapBlurShader", L"MiniMapBlurShader.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("MiniMapShader2", L"MiniMapShader2.hlsl", "PS", "VS");
	TheDX11ShaderManager::Instance()->LoadShader("MiniMapClearShader", L"MiniMapClearShader.hlsl", "PS", "VS");
}

void LoadState::OnActivated()
{
	DX11::ClearColour(0.0f, 0.0f, 0.0f, 1.0f);
	m_loadingText.Update("Loading Game Objects");
	m_loadingText.Translate(D3DXVECTOR3(0.0f, 0.0f, 0.0f));
	m_loadingText.Draw();

	TheScreenManager::Instance()->FlipBuffers();
	//TheConfigManager::Instance()->Load("../../Config/config.info");
	TheConfigManager::Instance()->LoadInfoSettings("../../Config/maze.info");
	//LoadGameObjects(L"../../Game_Objects/test_gameobjects.txt");

	//TheGame::Instance()->SetGameState(TheTestState::Instance());
	TheGame::Instance()->SetGameState(TheTitleScreenState::Instance());
}

void LoadState::OnDeactivated()
{

}